home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-12-07 | 48.6 KB | 1,669 lines |
-
-
-
-
-
-
-
-
- Decode It!(TM)
-
-
-
- The Binary Data Fourth Generation Language(TM)
-
-
-
- Version 1.0
-
-
- Users' Manual
-
-
-
-
- Created by
-
-
- Bob Preston
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Axiom Innovations
-
- 54 Settlers Farm Road
-
- Monroe, Connecticut 06468
-
-
- Copyright 1992 Axiom Innovations. All Rights Reserved.
- Printed in the United States of America.
-
-
- Decode It!(TM) and Decode It! 4GL(TM) are trademarks of Axiom
- Innovations. All trademarks and registered trademarks referenced within
- this document are the property of their respective owners.
-
-
-
-
- LICENSE AGREEMENT
-
-
-
- USE OF THIS PRODUCT BINDS YOU TO THE TERMS OF THIS LICENSE AGREEMENT.
- PLEASE READ THE AGREEMENT CAREFULLY AND DO NOT USE THIS PRODUCT IF YOU DO
- NOT AGREE TO THE TERMS OF THE AGREEMENT.
-
-
-
- 1. LICENSE. You may use this product for an evaluation period of 30
- days. After the evaluation period you are required to purchase a
- registered copy. Axiom Innovations grants permission for this shareware
- product to be copied and distributed, if no fees are charged. Otherwise,
- you must get written permission from Axiom Innovations to distribute
- copies of this product. Said permission is granted only for the
- distribution of unaltered and intact copies of this product.
-
-
- 2. COPYRIGHT. This product is licensed to you, for your own use. This
- is copyrighted software. You are not obtaining title to the product or
- any copyright rights. You may not sublicense, rent, lease, convey,
- modify, translate, decompile, or disassemble this product, in whole or in
- part, except as expressly provided for in this license.
-
-
- 3. COPIES. You may make as many copies of this product as you need for
- back-up purposes. You may use this product on more than one computer,
- provided there is no chance it will be used simultaneously on more than
- one computer. If you need to use the software on more than one computer
- simultaneously, please contact us for information about site licenses.
-
-
- 4. LIMITED WARRANTY. THIS PRODUCT IS LICENSED "AS IS" WITHOUT ANY
- WARRANTY OF ANY KIND, INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES
- OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ALL OF WHICH ARE
- EXPRESSLY AND SPECIFICALLY DISCLAIMED. Some states do not allow the
- exclusion of implied warranties, so the above limitation may not apply to
- you.
-
-
-
-
-
-
-
- Decode It! Version 1.0 Page 1
-
-
- 5. LIMITATION OF LIABILITY. IN NO EVENT SHALL AXIOM INNOVATIONS OR
- ANYONE ELSE WHO HAS BEEN INVOLVED IN THE CREATION, PRODUCTION, OR
- DELIVERY OF THIS PRODUCT BE LIABLE FOR ANY INDIRECT, CONSEQUENTIAL, OR
- INCIDENTAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THIS
- PRODUCT EVEN IF AXIOM INNOVATIONS HAS BEEN ADVISED OF SUCH DAMAGES OR
- CLAIMS. IN NO EVENT SHALL AXIOM INNOVATIONS LIABILITY FOR ANY DAMAGES
- EVER EXCEED THE PRICE PAID FOR THE LICENSE TO USE THIS PRODUCT,
- REGARDLESS OF THE FORM OF CLAIM. Some states do not allow the exclusion
- of the limit of liability for consequential or incidental damages, so the
- above limitation may not apply to you.
-
-
- 6. GOVERNING LAW. This agreement shall be governed by the laws of the
- State of Connecticut and shall inure to the benefit of Axiom Innovations
- and any successors, administrators, heirs and assigns. Any action or
- proceeding brought by either party against the other arising out of or
- related to this agreement shall be brought only in a STATE or FEDERAL
- COURT of competent jurisdiction located in Fairfield County, Connecticut.
- The parties hereby consent to in personam jurisdiction of said courts.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Decode It! Version 1.0 Page 2
-
-
-
- TABLE OF CONTENTS
-
-
-
-
- 1.0 What is Decode It!? ............................. 4
- 2.0 The Shareware Concept ........................... 5
- 3.0 System Requirements ............................. 5
- 4.0 Installation .................................... 6
- 5.0 Lets Try It Out! ................................ 6
- 6.0 Basic Features .................................. 10
- 6.1 Rules ........................................... 10
- 6.2 RECORDs ......................................... 11
- 6.3 END Command ..................................... 12
- 6.4 Criteria ........................................ 12
- 6.5 Undefined Values ................................ 13
- 6.6 Guidelines ...................................... 14
- 7.0 Advanced Features ............................... 15
- 7.1 Blocks .......................................... 15
- 7.2 Control Flow Commands ........................... 15
- 7.3 4GL Processor Commands .......................... 16
- 7.3.1 (ORDER) Command ............................... 16
- 7.3.2 (OMIT) Command ............................... 16
- 7.4 System Variable (.OFFSET) ....................... 17
- 8.0 Examples ........................................ 17
- 8.1 EXEINFO.RUL Revisited ........................... 17
- 8.2 C Unions ........................................ 17
- 8.3 IF ... THEN ... ELSE ............................ 19
- 8.4 IF ... AND/OR ................................... 19
- 9.0 Parameters ...................................... 20
- 10.0 4GL Quick Reference ............................ 21
- 10.1 Rules Format ................................... 21
- 10.2 Records and Blocks Formats ..................... 21
- 10.3 Criteria Format ................................ 22
- 10.4 Control Flow Commands .......................... 22
- 11.0 Registration ................................... 23
- Appendix A: Error Messages .......................... 24
- A.1 Main Program Errors ............................. 24
- A.2 4GL Processor Errors ............................ 24
- A.3 File Interpreter Errors ......................... 26
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Decode It! Version 1.0 Page 3
-
-
- 1.0 What is Decode It!?
-
- Decode It! is a simple, yet powerful fourth generation language (4GL)
- tailored for binary data interpretation. It excels in interpreting
- binary files containing fixed or variable length records and multiple
- record layouts.
-
- By applying your data format rules to raw binary data, Decode It! exposes
- the underlying structure of binary information and transforms it into
- readable ASCII text. This text can be redirected to a file, or piped to
- MORE and LIST. You specify the format, so data is displayed the way you
- want to see it.
-
- In addition, Decode It! opens up binary data to the world of text
- manipulation tools. Once created, Decode It! files can be used with
- DIFF, AWK, GREP, Norton's TS, and any other text utility.
-
- Some of Decode It!'s features are:
-
- Easy installation on single user and local area network systems
- (not copy protected).
-
- Easy to use Fourth Generation Language (4GL): programs are
- created using your favorite text editor.
-
- Borland dBase II, III, IV, and Lotus 1-2-3 4GL rule files are
- included! Decode your database and spreadsheet files right out
- of the box.
-
- Allows data to be grouped into 1 byte, 2 byte, 4 byte, or
- floating point values, and assigns each to a label.
- Furthermore, values can be combined into records (structures),
- with a label assigned to each.
-
- Binary data can be decoded using either Byte Forward or Byte
- Reverse ordering.
-
- Displays a value as decimal, hexadecimal, or as a character
- string.
-
- Permits criteria to be assigned to each data format rule. The
- criteria must be fulfilled for the rule to be selected.
-
- Select which part of a binary file you wish to decode, or
- decode the entire file.
-
- Edit the decoded binary data and store in original binary file
- (registered users only).
-
- Compile your rules into a stand-alone program with no royalties
- (registered users only).
-
-
-
-
-
-
- Decode It! Version 1.0 Page 4
-
-
- 2.0 The Shareware Concept
-
- Decode It! is distributed as Shareware: it is not "freeware" and it is
- not "public domain". Shareware allows you to try fully-featured,
- professional software before you buy it. Typically, you can obtain a
- shareware program from a distributor for a small handling fee (less than
- $10). Alternatively, you can download shareware from most electronic
- bulletin boards using a modem. You are permitted to use the software for
- an evaluation period (typically 30 days). After the evaluation period,
- you are obligated to register your software with the author.
-
-
- As a registered Decode It! user, you will receive:
-
- Two must-have utilities:
-
- 1) a program that allows you to edit and store
- decoded data back into the binary file; and
-
- 2) a Decode It! compiler for creating your own
- stand-alone decoder programs (royalty-free).
-
- A handsomely printed user manual.
-
- One month free problem and technical support.
-
- Upgrade notices (and special upgrade deals on future versions
- of Decode It!).
-
-
- Shareware provides you with a greater variety of software to choose from,
- as well as a big selection of hard-to-find, specialized software. Retail
- channels simply cannot stock as wide a variety of software as shareware
- distribution. Furthermore, to find specialized software, shareware is
- typically your only choice. Shareware also offers the ultimate
- satisfaction guarantee: if you are not satisfied with a product during
- the evaluation period, you can just stop using it. The shareware concept
- has been so successful that many retail software products are now
- distributed as shareware.
-
-
-
- 3.0 System Requirements
-
- Decode It! requires the following to operate:
-
- PC/XT (or faster) computer with at least 512K RAM,
-
- DOS version 3.0 or higher.
-
- A hard disk is recommended but not required.
-
-
-
-
-
-
- Decode It! Version 1.0 Page 5
-
-
- 4.0 Installation
-
- Decode It! can be installed on either a floppy or hard disk system. To
- begin the installation, insert the Decode It! disk into floppy disk drive
- A:. If you are using a two floppy system, insert a bootable target disk
- into floppy disk drive B:. Next, log onto drive A: by typing:
-
- A:<RETURN>
-
- where <RETURN> is the RETURN (or ENTER) key. Run the install program by
- typing:
-
- DINSTALL<RETURN>
-
- DINSTALL will first prompt you for the drive on which to install Decode
- It!. If installing on your primary hard drive, enter the letter C;
- otherwise, if installing on a floppy disk, you should enter the letter B.
- Next, DINSTALL will ask you if you actually want to install Decode It! on
- the target drive. If you did not answer the previous question correctly,
- select N at this point to abort the installation process. By answering
- Y, DINSTALL will install Decode It! and update the PATH statement in your
- AUTOEXEC.BAT file. Note that updating the PATH statement is crucial, for
- it allows Decode It! to find all its necessary files. After the
- installation is complete, you must reboot your computer for the new PATH
- to take effect.
-
- By the way, Decode It! can also be installed manually, by copying all the
- files from the installation disk into a DECODE subdirectory on your
- target drive and by updating the PATH statement to access this
- subdirectory. If you do not understand what this means, then just let
- DINSTALL handle it for you.
-
-
-
- 5.0 Lets Try It Out!
-
- If you're anxious to see the program work, lets try a few simple
- examples. If you have a Lotus .WK1 file, you can see Decode It! in
- action by typing the following:
-
- DECODE \decode\123.RUL <.WK1 file>
-
- where <.WK1 file> is your Lotus file. Hit the RETURN key to start it,
- and use Ctrl-C to get back to the DOS prompt.
-
- Likewise, you can decode your dBase II/III/IV .DBF files by using the
- rule files DBASE2.RUL, DBASE3.RUL and DBASE4.RUL, respectively.
-
- Now lets create a rule file from scratch. Suppose you were interested in
- seeing the header information at the beginning of the DECODE.EXE file.
- At the DOS prompt, type in the following:
-
-
-
-
-
-
- Decode It! Version 1.0 Page 6
-
-
- TYPE CON > EXEINFO.RUL
-
- ASCII Signature 2
-
- SHORT ImageSizeMod512
-
- SHORT FileSizeDiv512
-
- SHORT RelocationItems
-
- SHORT HeaderSizeDiv16
-
- SHORT MinimumHeapDiv16
-
- XSHORT MaximumHeapDiv16
-
- SHORT ImageStackSeg
-
- SHORT ExeStackSize
-
- XSHORT CheckSum
-
- SHORT ExeStartOffset
-
- SHORT ImageCodeSegment
-
- SHORT RelocationStart
-
- SHORT OverlayNumber
-
- EXIT
-
- <CTRL-Z><RETURN>
-
-
- where <CTRL-Z> is the Ctrl-Z key, and <RETURN> is the RETURN (or ENTER)
- key.
-
- The above rules that you typed in were stored in the file EXEINFO.RUL.
- Now we will use these rules to decode the EXE header. Type in the
- following at the DOS prompt:
-
- DECODE EXEINFO.RUL \decode\decode.exe
-
- Decode It! will respond with:
-
-
-
-
-
-
-
-
-
-
-
-
- Decode It! Version 1.0 Page 7
-
-
- .FILE: \decode\decode.exe
- .ORDER: LSB
-
- .OFFSET: 0x00000000
-
- Signature: "MZ"
-
- ImageSizeMod512: 0489
-
- FileSizeDiv512: 0032
-
- RelocationItems: 0008
-
- HeaderSizeDiv16: 0032
-
- MinimumHeapDiv16: 0265
-
- MaximumHeapDiv16: 0xFFFF
-
- ImageStackSeg: 1127
-
- ExeStackSize: 2048
-
- CheckSum: 0xD139
-
- ExeStartOffset: 1220
-
- ImageCodeSegment: 0000
-
- RelocationStart: 0030
-
- OverlayNumber: 0000
-
-
-
- Lets take a look at some of this information. The signature indicates
- that this file is indeed executable. We also know that the program
- requires 265 * 16 = 4240 bytes of heap space (by MinimumHeapDiv16), and
- uses 2048 bytes of stack space (by ExeStackSize).
-
- As another example, lets decode a text file with all control codes (for
- example, line feeds) exposed. Type in the following at the DOS prompt:
-
- TYPE CON > TEXT.RUL
-
- RECORD line -1
-
- WHILE line.character <> 10
- ASCII character -1
-
- END
-
- <CTRL-Z><RETURN>
-
-
-
-
- Decode It! Version 1.0 Page 8
-
-
- Now we'll decode TEXT.RUL, while also using it as the rule file, by
- entering at the DOS prompt:
-
- DECODE TEXT.RUL TEXT.RUL
-
- Decode It! will respond with:
-
-
- .FILE: TEXT.RUL
- .ORDER: LSB
-
- .OFFSET: 0x00000000
-
- line(00):
-
- character(00): "RECORD line -1"
- character(14): 13
- character(15): 10
-
- line(01):
-
- character(00): 13
- character(01): 10
-
- line(02):
-
- character(00): " WHILE line.character <> 10"
- character(28): 13
- character(29): 10
-
- line(03):
-
- character(00): " ASCII character -1"
- character(20): 13
- character(21): 10
-
- line(04):
-
- character(00): 13
- character(01): 10
-
- line(05):
-
- character(00): "END"
- character(03): 13
- character(04): 10
-
- line(06):
-
- character(00): 13
- character(01): 10
-
-
-
-
-
-
- Decode It! Version 1.0 Page 9
-
-
- You've just created two useful utilities:
-
- 1) A tool that displays DOS .EXE resource allocation,
-
- 2) A utility that not only finds embedded control characters
- in documents, but also counts the number of characters per line
- and the number of lines in the document.
-
- From these examples, its easy to see how Decode It! can become a valuable
- addition to your tool set.
-
-
-
- 6.0 Basic Features
-
- Decode It! uses rules (from a text file) to imply how binary data is
- stored. Each rule is assigned a label, and can be assigned matching
- criteria. If the criteria is fulfilled, Decode It! prints the data in
- the following format:
-
- <Label>: <Formatted Data>
-
- where <Label> is the rule's label, and <Formatted Data> is the data
- printed according to the format specified by the rule. Afterwards, the
- data is consumed by that rule's label, and the next rule is applied.
- Once the end of the rule file is reached, Decode It! cycles back to its
- beginning.
-
- In addition to rules, Decode It! supports commands that alter the flow of
- control through the rule file.
-
- Please note that all rules and commands must be specified in UPPERCASE.
-
-
-
- 6.1 Rules
-
- Rules are created using the following syntax:
-
-
- <Rule Type> <Label> [Instance Count]
-
-
- where <Rule Type> is one of the following:
-
-
-
-
-
-
-
-
-
-
-
-
-
- Decode It! Version 1.0 Page 10
-
-
- TYPE DESCRIPTION
- ------ -----------
- ASCII 1 byte character
- TINY 1 byte signed decimal
- XTINY 1 byte hexadecimal
- SHORT 2 byte signed decimal
- XSHORT 2 byte hexadecimal
- LONG 4 byte signed decimal
- XLONG 4 byte hexadecimal
- SFLOAT Single precision IEEE floating point
- DFLOAT Double precision IEEE floating point
-
- <Label> is an alphanumeric name that identifies the contents of
- the data; and,
-
- [Instance Count] is the optional number of times this rule is
- applied before preceding to the next one. Note that [Instance
- Count] can be an decimal integer constant or a label. If a
- label is specified, the last binary data assigned to that label
- is used. If the label's value is undefined, [Instance Count]
- is infinite (see Undefined Values section below). If [Instance
- Count] is omitted, it is assumed to be 1.
-
- [Instance Count] is always used as an unsigned integer with 32
- bit precision. This precision corresponds to the largest file
- size possible using MS-DOS. This maximum file size can be
- represented in Decode It! using the value -1. Consequently, an
- [Instance Count] equal to -1 is effectively infinite.
-
- Some examples of rules are:
-
- TINY SmallSize
- XLONG ManyLongs 55
- DFLOAT VariableFloats SmallSize
-
-
-
- 6.2 RECORDs
-
- Specifies that the following rules should be considered members
- of this structure (until an END command is specified). Its
- syntax is similar to the other rules, as follows:
-
- RECORD <Label> [Instance Count]
-
- where <Label> is a name that identifies the content of the
- record, and [Instance Count] is the optional number of RECORDs
- that can be selected using this rule. RECORDs can be nested.
-
-
-
-
-
-
-
-
-
- Decode It! Version 1.0 Page 11
-
-
- 6.3 END Command
-
- Ends the definition of a RECORD or Block (see Blocks section
- below). All rules between a RECORD and its associated END are
- members of that RECORD. Its syntax is:
-
- END [Record Size]
-
- where [Record Size] is an optional maximum size (in bytes) of a
- RECORD instance. [Record Size] can be a constant or a label
- (subject to Undefined Value logic). This size is useful for
- variable length records, as shown in the following example:
-
- SHORT RecSize
-
- RECORD VariableRec
-
- ASCII FixedField
-
- TINY VariableField -1
-
- END RecSize
-
- In this example, VariableField is bounded by the value of
- RecSize.
-
- Decode It! is tolerant of inconsistent nested Record Sizes.
- Suppose a rule file contains the following:
-
- RECORD foo
-
- RECORD bar
- TINY zap -1
- END 100
-
- TINY yeh -1
-
- END 50
-
- The rule "zap" will be selected 100 times; however, since the
- size of "foo" is less than "bar", the rule "yeh" will be
- skipped.
-
- Note that the END command cannot be subject to WHILE criteria.
-
-
- 6.4 Criteria
-
- The WHILE command allows a rule to be skipped if certain
- criteria is not met. It must be placed immediately before its
- corresponding rule, using the following syntax:
-
- WHILE <Operand1> <Operator> <Operand2>
-
-
-
-
- Decode It! Version 1.0 Page 12
-
-
-
- where <Operator> can be either:
-
- OPERATOR DESCRIPTION
- -------- -----------
- <=> Equivalence
- <> Not equal
- < Less than
- > Greater than
- <= Less than or equal to
- >= Greater than or equal to
-
-
- and <Operand1> and <Operand2> are SIGNED values that must be
- compared. Note that each of the operands can be either an
- decimal integer constant or a label. If a label is specified,
- the last binary data assigned to that label is used as the
- operand. If the label's value is undefined, the comparison is
- considered successful (see Undefined Values section below). If
- no WHILE command exists for a rule, the rule is applied to the
- data.
-
- Note that WHILEs can be nested by using the Block commands
- discussed below.
-
-
-
- 6.5 Undefined Values
-
- For each rule file cycle, the first time a rule's criteria is
- tested, the current value assigned to its label is marked as
- undefined. If the rule is once again selected, its new binary
- value is read from the file and marked as defined. If the rule
- is skipped, its value remains undefined. At startup, all
- values are undefined.
-
- An undefined value is interpreted as infinite when used as an
- instance count or record size, and a comparison on an undefined
- value is always successful. To demonstrate how this can be
- useful, the following example:
-
- WHILE Null_String <> 0
- ASCII Null_String -1
-
- matches on all null-terminated strings of arbitrary length.
-
-
-
-
-
-
-
-
-
-
-
-
- Decode It! Version 1.0 Page 13
-
-
- 6.6 Guidelines
-
- When creating a rule file, please observe the following:
-
- A maximum of 256 rules/commands can be defined.
-
- All rules and commands must be in UPPERCASE.
-
- One rule/command per line and one line per
- rule/command.
-
- Only one WHILE command is allowed per rule (unless
- Blocks are used).
-
- Tabs and/or spaces can be used as delimiters between
- rule/command arguments.
-
- If a label, used as an instance count, operand, or
- record size, refers to a member of a record, it must
- be fully qualified as follows:
-
- <Record>.[Nested Record Label(s).]<Label>
-
- Fully qualified labels must be unique.
-
- A label, used as an instance count, operand, or
- record size, cannot refer to a RECORD rule.
-
- Labels can contain only alphanumeric characters and
- underscores (_); furthermore, labels cannot begin
- with a digit.
-
- Labels must be less than or equal to 16 characters.
-
- Avoid using the following keywords as labels: ASCII,
- TINY, XTINY, SHORT, XSHORT, LONG, XLONG, SFLOAT,
- DFLOAT, WHILE, RETURN, NEXT, EXIT, BREAK, RESCIND,
- BEGIN, REPEAT, END. Even though these are acceptable
- labels, they will not be valid in future versions of
- Decode It!.
-
- All constant numbers must be decimal integers (base
- 10).
-
- Comments can be used in a rule file by preceding them
- with a pound symbol (#).
-
- Blank lines are permissible in the rule file.
-
-
-
-
-
-
-
-
-
- Decode It! Version 1.0 Page 14
-
-
- 7.0 Advanced Features
-
-
-
- 7.1 Blocks
-
- A Block allows a group of rules to be selected based on only
- one criteria statement. Two types of Blocks can be created:
- BEGIN/END and REPEAT/END. A BEGIN/END block is only selected
- once. A REPEAT/END block is re-invoked until its corresponding
- criteria no longer evaluates true. The END command that
- completes a block can contain an optional Record Size (see END
- Command section above). Like RECORDs, Blocks can be nested.
- Here are two examples of Blocks:
-
- SHORT foo
- WHILE foo <> 1
- BEGIN
-
- DFLOAT bar 2
- SFLOAT zap 2
-
- END
-
-
-
- REPEAT
-
- LONG foo 1
- TINY bar 3
- WHILE foo <=> 55
- BREAK
-
- END
-
- In the first example, the block is selected once if foo is not
- equal to 1. In the second, the block is always selected until
- foo is equal to 55.
-
-
-
- 7.2 Control Flow Commands
-
- Combined with Blocks and RECORDs, control flow commands provide
- a powerful way to alter the sequence of execution. Some of
- these commands allow execution to skip past the end of the
- current Block/RECORD, to go to the top of the rule file, and to
- exit the program. The full list of Control Flow Commands
- follows:
-
-
-
-
-
-
-
-
- Decode It! Version 1.0 Page 15
-
-
- COMMAND DESCRIPTION
- ------- -----------
- EXIT Exit the program
- RETURN Resume at top of rule file
- RESCIND Go to end of last 2 nested blocks
- BREAK Go to end of current block
- NEXT Next invocation of this block
-
- The usefulness of these commands is demonstrated in the
- Examples section below.
-
-
-
- 7.3 4GL Processor Commands
-
- Before your rules are applied to binary data, they are first
- processed by the program DCODE4GL, to resolve label references
- and to check for syntax errors. The following commands are
- used exclusively by DCODE4GL (thats why they are surrounded by
- parenthesis). One important note is that these commands have
- GLOBAL scope: once used, they affect the entire module and are
- not subject to WHILE criteria.
-
- 7.3.1 (ORDER) Command
-
- The (ORDER) command specifies the byte ordering of
- the binary data. On IBM PCs, multi-byte data is
- stored in Byte Reverse order. That is, the least
- significant byte(s) of the data are stored first.
- Decode It! is flexible enough to decode binary data
- stored in Byte Forward order (most significant
- byte(s) first). The two commands are:
-
- (ORDER) LSB
-
- (ORDER) MSB
-
- where LSB and MSB stand for least significant byte
- and most significant byte, respectively. Only one
- (ORDER) command can be used in a rule file. If the
- (ORDER) command is omitted, LSB is assumed.
-
-
- 7.3.2 (OMIT) Command
-
- The (OMIT) command allows data to be consumed by a
- rule without it being printed. Its syntax is:
-
- (OMIT) <Label>
-
- where <Label> is the label of a rule specified
- elsewhere in the file. An example is:
-
-
-
-
-
- Decode It! Version 1.0 Page 16
-
-
-
- WHILE Words <> 32
- ASCII Words -1
-
- WHILE NeedlessWords <> 10
- ASCII NeedlessWords -1
-
- (OMIT) NeedlessWords
-
- Here only the characters up to and including the
- first space in each line are printed.
-
-
-
- 7.4 System Variable (.OFFSET)
-
- .OFFSET is a label that represents the absolute offset in the
- binary file. It can be used wherever labels are acceptable.
- In the following example
-
- WHILE .OFFSET <> 100
- TINY Skip -1
- (OMIT) Skip
-
- the first 100 bytes of the binary file are omitted.
-
-
- 8.0 Examples
-
- 8.1 EXEINFO.RUL Revisited
-
- In the tutorial section, we created a rule file called
- EXEINFO.RUL that displayed the header information at the
- beginning of a DOS .EXE file. Suppose we were only interested
- in the stack size of an executable. We could then rewrite
- EXEINFO as follows:
-
- WHILE .OFFSET <> 16
- SHORT Ignore
-
- (OMIT) Ignore
-
- SHORT ExeStackSize
-
- EXIT
-
-
- 8.2 C Unions
-
- C Unions can be decoded using Blocks with corresponding WHILE
- criteria. For example, if a binary file contains data for the
- following union:
-
-
-
-
-
- Decode It! Version 1.0 Page 17
-
-
-
- char cDataType;
- union
- {
-
- char cValue; /* If cDataType = 0 */
- short iValue; /* If cDataType = 1 */
- struct /* If cDataType = 2 */
- {
-
- long lVal1;
- long lVal2;
-
- } rValue;
-
- }
-
-
- this can be represented in the rule file as follows:
-
- TINY cDataType
-
- BEGIN
-
- WHILE cDataType <=> 0
- BEGIN
-
- TINY cValue
- RESCIND
-
- END
-
- WHILE cDataType <=> 1
- BEGIN
-
- SHORT iValue
- RESCIND
-
- END
-
- WHILE cDataType <=> 2
- RECORD rValue
-
- LONG lVal1
- LONG lVal2
- RESCIND
-
- END
-
- END
-
-
-
-
-
-
-
- Decode It! Version 1.0 Page 18
-
-
- 8.3 IF ... THEN ... ELSE
-
- Decode It! can support multi-way branching (as in IF/THEN/ELSE)
- as follows. Suppose we want to select the rule
-
- LONG l
-
- if x is equal to z; otherwise, we want to select the rule
-
- SHORT s
-
- This can be represented as:
-
- BEGIN
-
- WHILE x <=> z
- BEGIN
-
- LONG l
- RESCIND
-
- END
-
- SHORT s
-
- END
-
-
- Furthermore, CASE statements can be created using the method
- shown in the C Unions section above.
-
-
- 8.4 IF ... AND/OR
-
- Boolean AND/OR logic can be constructed using Decode It! as
- shown in the following examples. Suppose we want to select the
- rule
-
- DFLOAT pi
-
- if x is equal to 0 AND y is equal to 11. The rule file can
- represent this as:
-
- WHILE x <=> 0
- BEGIN
-
- WHILE y <=> 11
- DFLOAT pi
-
- END
-
- Alternatively, suppose we only want to select "pi" if x is
- equal to 22 OR y is equal to 33. This can be constructed as:
-
-
-
-
- Decode It! Version 1.0 Page 19
-
-
- BEGIN
-
- WHILE x <> 22
- BEGIN
-
- WHILE y <> 33
- RESCIND
-
- END
- DFLOAT pi
-
- END
-
-
-
- 9.0 Parameters
-
- Decode It! is executed from the DOS prompt using the following syntax:
-
- DECODE <rule file> <binary file> [L<length>] [S<start>] [W<width>]
-
- where
-
- <rule file> is a file containing Decode It! 4GL rules. If a
- hyphen (-) is used, the rules are read from the console.
-
- <binary file> is the binary data to decode.
-
- [L<length>] is an optional length of binary data (in bytes) to
- decode. Its default is the entire binary file. Length can be
- specified as hexadecimal by preceding the number with '0x'.
-
- [S<start>] is an optional file offset from which to start
- decoding. Its default is the beginning of the binary file.
- Start can be specified as hexadecimal by preceding the number
- with '0x'.
-
- [W<width>] is the optional maximum width of displayed ASCII
- strings. If no width is specified, ASCII strings are displayed
- so that they fit on a standard monitor. Width can be specified
- as hexadecimal by preceding the number with '0x'.
-
- The output from Decode It! can be redirected or piped to another process.
-
- Note that Decode It! uses a temporary file while executing. The file is
- created in the directory specified by the TMP environment variable, or in
- the current directory if there is no TMP variable. The name of the temp
- file is of the form 'decodeXX', where XX is a consecutively increasing
- number. In addition, the program DINSTALL uses the temporary file
- 'dcodeaut.new' when updating autoexec.bat.
-
- DCODE4GL, the 4GL processor program, will use extended/expanded memory
- when necessary, if either is available.
-
-
-
-
- Decode It! Version 1.0 Page 20
-
-
- 10.0 4GL Quick Reference
-
-
-
- 10.1 Rules Format
-
-
- <Rule Type> <Label> [Instance Count]
-
-
- where <Rule Type> can be:
-
-
- TYPE DESCRIPTION
- ------ -----------
- ASCII 1 byte character
- TINY 1 byte signed decimal
- XTINY 1 byte hexadecimal
- SHORT 2 byte signed decimal
- XSHORT 2 byte hexadecimal
- LONG 4 byte signed decimal
- XLONG 4 byte hexadecimal
- SFLOAT Single precision IEEE floating point
- DFLOAT Double precision IEEE floating point
-
-
-
- 10.2 Records and Blocks Formats
-
-
- RECORD <Label> [Instance Count]
-
- BEGIN
-
- REPEAT
-
-
-
- Each Record/Block is terminated by an END command:
-
-
- END [Size]
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Decode It! Version 1.0 Page 21
-
-
- 10.3 Criteria Format
-
-
- WHILE <Operand1> <Operator> <Operand2>
-
-
- where <Operator> can be:
-
-
- OPERATOR DESCRIPTION
- -------- -----------
- <=> Equivalence
- <> Not equal
- < Less than
- > Greater than
- <= Less than or equal to
- >= Greater than or equal to
-
-
-
- 10.4 Control Flow Commands
-
-
- COMMAND DESCRIPTION
- ------- -----------
- EXIT Exit the program
- RETURN Resume at top of rule file
- RESCIND Go to end of last 2 nested blocks
- BREAK Go to end of current block
- NEXT Next invocation of this block
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Decode It! Version 1.0 Page 22
-
-
- 11.0 Registration
-
- --------------------------------------------------------------
- Decode It! V1.0 Registration Payment Form (valid through 1995)
- --------------------------------------------------------------
-
- S1006-0 Date: _____________
-
- Name: ___________________________________________________________
-
- Company: ________________________________________________________
-
- Address: ________________________________________________________
-
- City: ___________________________________________________________
-
- State/Country: ________________________ Zip: ____________________
-
- Phone: (_____) _____ - ______
-
- What type of floppy disk? [] 5-1/4" [] 3-1/2"
-
- ITEM QTY UNIT COST TOTAL
- ---------------------- --- --------- -------
- Decode It! Version 1.0 ___ x $35.00 = $______
-
- (CT state residents only) 6% sales tax $______
-
- Shipping and Handling: $______
- $5.00 Inside U.S.A. (not P.O. Box)
- $5.00 APO or FPO U.S. address
- $7.00 P.O. Box
- $8.00 Western Hemisphere (except USA)
- $16.00 Eastern Hemisphere
- TOTAL $______
-
- CHECKS AND MONEY ORDERS MUST BE U.S. FUNDS DRAWN ON U.S. ACCOUNTS ONLY.
- Please send the above form with check or money order (payable to Axiom
- Innovations) to:
- Axiom Innovations
- 54 Settlers Farm Road
- Monroe, Connecticut 06468 USA
-
- Site licensing is available. Please contact us.
-
- As an incentive to registering, future versions of Decode It! will be
- available to registered users at discounted prices.
-
- Axiom Innovations is dedicated to providing innovative tools for
- increasing programmer productivity. Watch for useful new shareware
- products from us on your favorite bulletin boards and from shareware
- distributors. If you have any comments or suggestions on how we can make
- our software better, please contact us. We would love to hear from you.
- Congratulations on your decision to purchase Decode It!, and thank you
- for supporting the shareware concept.
-
-
- Decode It! Version 1.0 Page 23
-
-
- Appendix A: Error Messages
-
- A.1 Main Program Errors
-
- Error: Could not create temporary file name
- Cause: Disk full, write protection, etc.
- Remedy: Check if disk is full or write protected.
- Delete any Decode It! temporary files.
-
- Error: Could not duplicate stdout
- Cause: Too many open files.
- Remedy: Increase the FILES= statement in CONFIG.SYS
-
- Error: Could not find DCODE4GL.EXE in PATH
- Cause: PATH does not contain DECODE directory.
- Remedy: Update PATH= statement in AUTOEXEC.BAT and reboot.
-
- Error: Could not find DCODEFI.EXE in PATH
- Cause: PATH does not contain DECODE directory.
- Remedy: Update PATH= statement in AUTOEXEC.BAT and reboot.
-
- Error: Could not redirect stdin
- Cause: Too many open files.
- Remedy: Increase the FILES= statement in CONFIG.SYS.
-
- Error: Could not redirect stdout
- Cause: Too many open files or write protection.
- Remedy: Dependent upon cause.
-
-
- A.2 4GL Processor Errors
-
- Error: Byte ORDERing already specified
- Cause: Rule file contains several (ORDER) commands.
- Remedy: Only one (ORDER) command is permitted.
-
- Error: Illegal byte ORDERing
- Cause: Unrecognized argument.
- Remedy: Use either 'LSB' or 'MSB'.
-
- Error: Illegal character(s) in label
- Cause: Labels can only contain alphanumerics and underscores.
- Labels cannot begin with a digit.
- Remedy: Rename label.
-
- Error: Illegal command
- Cause: Unrecognized command.
- Remedy: Use proper command (in UPPERCASE).
-
- Error: Illegal END command
- Cause: Unexpected END command.
- Remedy: Remove END command and re-check program logic.
-
-
-
-
-
- Decode It! Version 1.0 Page 24
-
-
- Error: Illegal number of arguments
- Cause: Too few or too many arguments.
- Remedy: Refer to Users' Manual for correct usage.
- Arguments must be separated by spaces.
-
- Error: Illegal WHILE operator
- Cause: Operator is not valid.
- Remedy: Refer to Users' Manual for valid operators.
-
- Error: Instance count cannot reference a RECORD
- Cause: A record is used as an instance count.
- Remedy: Use a non-record rule as an instance count.
-
- Error: Invalid instance count
- Cause: Instance count is non-numeric or zero.
- Remedy: Use a valid label or number.
-
- Error: Invalid OMIT label
- Cause: OMIT label not found.
- Remedy: Use a valid label.
-
- Error: Invalid RECORD size
- Cause: Size is non-numeric or zero.
- Remedy: Use a valid label or number.
-
- Error: Invalid WHILE operand 1
- Cause: Operand is non-numeric.
- Remedy: Use a valid label or number.
-
- Error: Invalid WHILE operand 2
- Cause: Operand is non-numeric.
- Remedy: Use a valid label or number.
-
- Error: Label already defined
- Cause: Fully qualified labels must be unique.
- Remedy: Change label.
-
- Error: Label too long
- Cause: Labels must be <= 16 characters.
- Remedy: Shorten label.
-
- Error: No corresponding END
- Cause: A record or block is not terminated with an END.
- Remedy: Re-check program logic.
-
- Error: No Member(s) in RECORD
- Cause: Records must contain at least one rule.
- Remedy: Delete the unused record.
-
- Error: No rule specified after WHILE command
- Cause: The rule file ends with a WHILE command.
- Remedy: Delete last unused WHILE.
-
-
-
-
-
- Decode It! Version 1.0 Page 25
-
-
- Error: No rule(s) in BEGIN/REPEAT block
- Cause: Blocks must contain at least one rule.
- Remedy: Delete the unused block.
-
- Error: No rules specified
- Cause: The rule file does not contain at least one rule.
- Remedy: Add rules to rule file.
-
- Error: Size cannot reference a RECORD
- Cause: A record is used as a size.
- Remedy: Use a non-record rule as a size.
-
- Error: Too many rules
- Cause: A maximum of 256 rules/commands can be defined.
- Remedy: Use fewer rules and commands.
-
- Error: WHILE criteria already specified
- Cause: WHILEs cannot be nested.
- Remedy: Use BEGIN/END blocks.
-
- Error: WHILE criteria specified for (OMIT) command
- Cause: (OMIT) is not subject to WHILE criteria.
- Remedy: Remove WHILE statement.
-
- Error: WHILE criteria specified for (ORDER) command
- Cause: (ORDER) is not subject to WHILE criteria.
- Remedy: Remove WHILE statement.
-
- Error: WHILE criteria specified for END command
- Cause: END is not subject to WHILE criteria.
- Remedy: Remove WHILE statement.
-
- Error: WHILE operand 1 cannot reference a RECORD
- Cause: A record is used as an operand.
- Remedy: Use a non-record rule as an operand.
-
- Error: WHILE operand 2 cannot reference a RECORD
- Cause: A record is used as an operand.
- Remedy: Use a non-record rule as an operand.
-
- A.3 File Interpreter Errors
-
- Error: Cannot open <binary file>
- Cause: File cannot be found, no file handles left, etc.
- Remedy: Dependent upon cause.
-
- Error: Cannot read <EXE file>
- Cause: File cannot be found, no file handles left, etc.
- Remedy: Dependent upon cause.
-
- Error: Cannot read file info. from <binary file>
- Cause: Not enough FCBS.
- Remedy: Increase the first number in the FCBS= statement in CONFIG.SYS.
-
-
-
-
- Decode It! Version 1.0 Page 26
-
-
- Error: Error reading rule information
- Cause: Ctrl-C was hit.
- Remedy: Retry.
-
- Error: Error reading rule(s)
- Cause: Ctrl-C was hit.
- Remedy: Retry.
-
- Error: Error reading WHILE(s)
- Cause: Ctrl-C was hit.
- Remedy: Retry.
-
- Error: Floating point conversion failed for <number>
- Cause: Float could not be truncated to integer.
- Remedy: Change program logic to avoid comparing float.
-
- Error: Invalid length parameter
- Cause: Length is either non-numeric, zero, or too big.
- Remedy: Use appropriate length.
-
- Error: Invalid start parameter
- Cause: Start is non-numeric.
- Remedy: Use correct start.
-
- Error: Invalid width parameter
- Cause: Width is either non-numeric or zero.
- Remedy: Use appropriate width.
-
- Error: No rule(s) match
- Cause: The program went into an infinite loop.
- Remedy: Re-check program logic.
-
- Error: Too many rules
- Cause: Intermediate 4GL file is corrupted.
- Remedy: Retry.
-
- Error: Unexpected EOF on read
- Cause: EOF reached before a multi-byte value was filled.
- Remedy: Re-check program logic.
-
- Error: Unrecognizable parameter
- Cause: Unknown parameter specified on command line.
- Remedy: Refer to Users' Manual for proper usage.
-
- Error: Version mismatch
- Cause: DCODE4GL.EXE and DCODEFI.EXE versions do not match.
- Remedy: Install newer version of Decode It!.
-
- Error: Width cannot be greater than 1024
- Cause: Width parameter too big.
- Remedy: Use appropriate width.
-
-
-
-
-
-
- Decode It! Version 1.0 Page 27
-